<!--
 * @Author: 周洋 1430536748@qq.com
 * @Date: 2024-08-10 15:56:57
 * @LastEditors: 周洋 1430536748@qq.com
 * @LastEditTime: 2024-08-23 09:42:00
 * @version: 1.2.5
 * @Description: 搜索表单
-->
<script setup lang="ts">
import Inline from '../inline/index.vue';
import { Search, Refresh } from '@element-plus/icons-vue';
import { props, Emits } from '../props';
const { FormItems, data, customClass, labelWidth } = defineProps(props);
const inlineRef = ref<any>();
const submitLoading = ref<boolean>(false);
const emit = defineEmits<Emits>();
const resetClick = (data: any) => {
    inlineRef.value.resetForm();
    submitClick(data);
}
const submitClick = (data: any) => {
    submitLoading.value = true;
    emit('onSearch', data, closeLoading);
    timeout(5000)
}
function closeLoading() {
    submitLoading.value = false;
}
function timeout(num: number) {
    setTimeout(() => {
        if (submitLoading.value) {
            submitLoading.value = false;
            console.log("请求超时");
        }
    }, num)
}
</script>
<template>
    <Inline ref="inlineRef" :FormItems="FormItems" :data="data" :custom-class="customClass" :label-width="labelWidth">
        <el-form-item>
            <el-button type="primary" auto-insert-space :loading="submitLoading" :icon="Search"
                @click="submitClick(data)">{{ $t(`button.query`) }}</el-button>
            &nbsp;&nbsp;
            <el-button type="info" auto-insert-space native-type="reset" :icon="Refresh" @click="resetClick(data)">{{
                $t(`button.reset`) }}</el-button>
        </el-form-item>
    </Inline>
</template>
<style scoped lang="scss"></style>